# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models, _


import logging
_logger = logging.getLogger(__name__)

class HrExpenseCheckWizard(models.TransientModel):

    _name = "hr.expense.check.wizard"
    _description = "Expense Check Wizard"

    reason = fields.Char(string='Reason', required=True)
    check_department_id = fields.Many2one('hr.department', string='Check Department', required=True )
    hr_expense_sheet_id = fields.Many2one('hr.expense.sheet')
    #line_ids = fields.One2many('hr.expense.check.wizard.line', 'wizard_id' )

    @api.model
    def default_get(self, fields):
        res = super(HrExpenseCheckWizard, self).default_get(fields)
        active_ids = self.env.context.get('active_ids', [])
        
        res.update({
            'hr_expense_sheet_id': active_ids[0] if active_ids else False,
        })
        
        return res

    @api.multi
    def next_check(self):
        self.ensure_one()
        self.hr_expense_sheet_id.next_check(self.check_department_id)
        
        return {'type': 'ir.actions.act_window_close'}





""" 

class HrExpenseCheckWizardLine(models.TransientModel):

    _name = "hr.expense.check.wizard.line"
    _description = "Expense Check Wizard Line"

    wizard_id = fields.Many2one('hr.expense.check.wizard')

    hr_expense_id = fields.Many2one('hr.expense')
    hr_expense_sheet_id = fields.Many2one('hr.expense.sheet', related='wizard_id.hr_expense_sheet_id')

"""
